# Makefile for loader project
# Version: 1.1

# 编译器和标志
CC = gcc
CFLAGS = -s -O2 -Wall

# OpenSSL库路径
OPENSSL_LIBS = -lcrypto -ldl

# 默认目标
.PHONY: all clean test

all: test_main test_loader

# 编译测试主程序
test_main: test_main.c
	$(CC) $(CFLAGS) -o $@ $<

# 编译loader
test_loader: new_loader.c
	$(CC) $(CFLAGS) -o $@ $< $(OPENSSL_LIBS)

# 构建测试包
build: test_main test_loader
	./loader_build.sh test_main test_loader $(CC) x86

# 运行测试
test: build
	./test_loader

# 清理
clean:
	rm -f test_main test_loader
	rm -f *.enc *.bin iv.bin
	rm -rf rsdp_test

# 安装依赖
install-deps:
	sudo apt-get update && sudo apt-get install -y libssl-dev